#!/bin/bash

URL="http://127.0.0.1:80"

status_code=$(curl -s -o /dev/null --max-time 5 -w "%{http_code}" $URL)
if [ "$status_code" -ne 200 ]; then
    sleep 3
    status_code=$(curl -s -o /dev/null --max-time 5 -w "%{http_code}" $URL)
    if [ "$status_code" -ne 200 ]; then
        systemctl restart keepalived
    fi
fi